<!DOCTYPE html>
<html lang="en">
<include file="CommonSidebar:common-head"/>
<link href="__ROOT__/Application/Admin/Public/css/jquery.datetimepicker.css" rel="stylesheet">
<body>
<link href="__ROOT__/Application/Admin/Public/css/cropper/cropper.min.css" rel="stylesheet">
<link href="__ROOT__/Application/Admin/Public/css/main.css" rel="stylesheet">
<js href="__ROOT__/Application/Admin/Public/ueditor/ueditor.config.js"/>
<js href="__ROOT__/Application/Admin/Public/ueditor/ueditor.all.min.js"/>
<js href="__ROOT__/Application/Admin/Public/js/jquery-2.0.2.js"/>

<div id="wrapper">

    <!-- Navigation -->
    <include file="CommonSidebar:common-navbar"/>
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">添加/编辑书籍</h1>
            </div>
        </div>

        <!-- /.row -->
        <div class="row">
            <div class="col-lg-12">
                <div class="row">
                    <div class="col-md-12">
                        <div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
                            <div class="panel panel-default">
                                <div class="panel-heading" role="tab" id="headingOne">
                                    <h4 class="panel-title">
                                        <a role="button" data-toggle="collapse" data-parent="#accordion"
                                           href="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
                                            添加/编辑书籍
                                        </a>
                                    </h4>
                                </div>
                                <div id="collapseOne" class="panel-collapse collapse in" role="tabpanel"
                                     aria-labelledby="headingOne">
                                    <div class="panel-body">
                                        <form id="editStoreForm" action="{:U('AddHanld')}"
                                              class="form-horizontal"
                                              method="post">

                                            <input name="ID" type="hidden" value="{$DATA['ID']}">

                                            <div class="form-group">
                                                <div style="margin-top:20px;">
                                                    <label class="col-sm-2 control-label">商品图</label><span
                                                        style="color:red;">*</span>

                                                    <div class="goods-img-list">

                                                        <div class="goods-img-item">
                                                            <img style="height: 100px" src="{$DATA['PIC_URL']}" alt="">
                                                            <span class="glyphicon close-goods-img glyphicon-remove-circle"></span>
                                                        </div>


                                                        <img height="100px" class="add-goods-img avatar-view"
                                                             src="__ROOT__/Application/Admin/Public/images/default.png"
                                                             alt=""
                                                             style="margin-left:20px">
                                                    </div>
                                                    <p class="help-block" style="display: none">上传图片</p>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">一级分类:</label>

                                                <div class="col-sm-3">
                                                    <select id="status" type="text" class="form-control"
                                                            name="region_one">
                                                        <option value="{$DATA['region_one']}">{$DATA['region_one']}
                                                        </option>
                                                        <foreach name="yjfldata" item="v" key="k">
                                                            <option value="{$v.region_id}">{$v.region_name}</option>
                                                        </foreach>
                                                    </select>
                                                </div>
                                                <label class="col-sm-2 control-label">二级分类:</label>

                                                <div class="col-sm-3">

                                                    <select id="two" type="text" class="form-control" name="region_two">
                                                        <option value="{$DATA['region_two']}">{$DATA['region_two']}
                                                        </option>
                                                    </select>
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">书籍名称:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="TITLE"
                                                           value="{$DATA['TITLE']}">
                                                </div>
                                                <label class="col-sm-2 control-label">条形码ISBN:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="ISBN"
                                                           value="{$DATA['ISBN']}">
                                                </div>
                                            </div>
                                            <div class="form-group">

                                                <label class="col-sm-2 control-label">作者:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="AUTHOR"
                                                           value="{$DATA['AUTHOR']}">
                                                </div>

                                                <label class="col-sm-2 control-label">出版社:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="PRESS"
                                                           value="{$DATA['PRESS']}">
                                                </div>

                                            </div>
                                            <div class="form-group">

                                                <label class="col-sm-2 control-label">出版日期:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="PUBLICATION_DATE"
                                                           value="{$DATA['PUBLICATION_DATE']}">
                                                </div>

                                                <label class="col-sm-2 control-label">包装规格:</label>

                                                <div class="col-sm-3">

                                                    <select type="text" class="form-control"
                                                            name="PACKING_SPECIFICATION">
                                                        <option value="{$DATA['PACKING_SPECIFICATION']}">
                                                            {$DATA['PACKING_SPECIFICATION']}
                                                        </option>
                                                        <foreach name="BOOK_PACKING" item="v" key="k">
                                                            <option value="{$v}">{$v}</option>
                                                        </foreach>
                                                    </select>
                                                </div>

                                            </div>
                                            <div class="form-group">

                                                <label class="col-sm-2 control-label">书籍开本:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="BOOK_SIZE"
                                                           value="{$DATA['BOOK_SIZE']}">
                                                </div>

                                                <label class="col-sm-2 control-label">语言:</label>

                                                <div class="col-sm-3">
                                                    <select type="text" class="form-control" name="LANGUAGES">
                                                        <option value="{$DATA['LANGUAGES']}">{$DATA['LANGUAGES']}
                                                        </option>
                                                        <foreach name="BOOK_LANGUAGES" item="v" key="k">
                                                            <option value="{$v}">{$v}</option>
                                                        </foreach>
                                                    </select>
                                                </div>

                                            </div>
                                            <div class="form-group">

                                                <label class="col-sm-2 control-label">页数:</label>

                                                <div class="col-sm-3">
                                                    <input type="number" class="form-control" name="PAGE"
                                                           value="{$DATA['PAGE']}">
                                                </div>

                                                <label class="col-sm-2 control-label">预计阅读时间(天):</label>

                                                <div class="col-sm-3">
                                                    <input type="number" class="form-control" name="YJ_READ_TIME"
                                                           value="{$DATA['YJ_READ_TIME']}">
                                                </div>

                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">阅读年龄:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="AGE"
                                                           value="{$DATA['AGE']}">
                                                </div>

                                                <label class="col-sm-2 control-label">库存:</label>

                                                <div class="col-sm-3">
                                                    <input type="number" class="form-control" name="STOCK" min="0"
                                                           value="{$DATA['STOCK']}">
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">原价:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="Y_PRICE"
                                                           value="{$DATA['Y_PRICE']}">
                                                </div>

                                                <label class="col-sm-2 control-label">销售价格:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="XS_PRICE"
                                                           value="{$DATA['XS_PRICE']}">
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">租金:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="RENT"
                                                           value="{$DATA['RENT']}">
                                                </div>

                                                <label class="col-sm-2 control-label">滞纳金:</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="ZN_PRICE"
                                                           value="{$DATA['ZN_PRICE']}">
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">书籍新旧水平:</label>

                                                <div class="col-sm-3">
                                                    <select type="text" class="form-control" name="LEVEL">
                                                        <option value="{$DATA['LEVEL']}">{$DATA['LEVEL']}</option>
                                                        <foreach name="BOOK_LEVEL" item="v" key="k">
                                                            <option value="{$v}">{$v}</option>
                                                        </foreach>
                                                    </select>

                                                </div>

                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">书籍重量(g/克):</label>

                                                <div class="col-sm-3">
                                                    <input type="text" class="form-control" name="KG"
                                                           value="{$DATA['KG']}">
                                                </div>
                                                <label class="col-sm-2 control-label">书籍状态:</label>

                                                <div class="col-sm-3">
                                                    <select type="text" class="form-control" name="STATE">
                                                        <option value="{$DATA['STATE']}">{$DATA['STATE']}</option>
                                                        <foreach name="BOOK_STATE" item="v" key="k">
                                                            <option value="{$v}">{$v}</option>
                                                        </foreach>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">书籍模糊搜索关键词语句:</label>

                                                <div class="col-sm-8">
                                                    <input type="text" class="form-control" name="KEY"
                                                           value="{$DATA['KEY']}">
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label class="col-sm-2 control-label">书籍简介:</label>

                                                <div class="col-sm-8">
                                                    <textarea type="text" class="form-control" name="INFO" rows="10">{$DATA['INFO']}</textarea>
                                                </div>
                                            </div>


                                            <div class="form-group">
                                                <div class="col-sm-2 col-sm-offset-2">
                                                    <button type="submit" class="btn btn-block btn-primary">保存</button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>

    </div>
    <!-- /#page-wrapper -->

</div>


<include file="CommonSidebar:common-script"/>
<!-- Custom Theme JavaScript -->
<script src="__ROOT__/Application/Admin/Public/dist/js/sb-admin-2.js"></script>
<script type="text/javascript" src="__ROOT__/Application/Admin/Public/js/uploadPreview.js"></script>
<script type="text/javascript" src="__ROOT__/Application/Admin/Public/js/jquery.form.min.js"></script>
<script type="text/javascript" src="__ROOT__/Application/Admin/Public/js/jquery.qrcode.min.js"></script>


<include file="Common:common-cropper"/>
<script src="__ROOT__/Application/Admin/Public/dist/js/sb-admin-2.js"></script>
<script type="text/javascript" src="__ROOT__/Application/Admin/Public/js/bootstrapValidator.js"></script>
<script src="__ROOT__/Application/Admin/Public/js/cropper/cropper.min.js"></script>
<script src="__ROOT__/Application/Admin/Public/js/figure.js"></script>


</body>
<script>
    $("select#status").change(function () {
        var ID = $(this).val();
        $.post("{:U('GetRegion_two')}",
                {ID: ID},
                function (data) {
                    $("#two").empty();
                    $.each(data, function (n, value) {
                        $("#two").append("<option value='" + value.region_name + "'>" + value.region_name + "</option>");
                    });

                });
    });
</script>
<script>
    $(function () {
        new CropAvatar({
            container: '#crop-avatar',
            workspaces: '__ROOT',
            formUrl: "{:U('Pics/Pics')}",
            submitDone: function (data) {
                console.log(data);
                var $avatarView = $('.avatar-view');
                if (data.state == 1) {
                    var imgUrl = data.picpath;
                    var imgUrlTH = data.data;
                    var html = ' <div class="goods-img-item">';
                    html += '<img style="height: 250px" src="' + '__ROOT__/' + imgUrl + '" alt="">';
                    html += '<span class="glyphicon close-goods-img glyphicon-remove-circle"></span>';
                    html += '<input type="hidden" value="' + imgUrlTH + '" name="thumbpicpath[]" >';
                    html += ' <input type="hidden" value="' + imgUrl + '" name="picpath[]" >';
                    html += '</div>';
                    $avatarView.before(html);
                    $avatarView.hide();
                } else {
                    alert('Failed to response');
                }
            },
            delete: function (e) {
                var _this = e.target;
                var flag = _this.className.indexOf('close-goods-img');
                var $avatarView = $('.avatar-view');
                if (flag >= 0) {
                    var $elem = $(_this);
                    if (confirm("确认移除？")) {
                        $avatarView.show();
                        $elem.parent(".goods-img-item").remove();
                        $avatarView.next("input[name='thumbpicpath']").val("");
                        $avatarView.next("input[name='picpath']").val("");
                        $('.add-goods-img').attr('src', options.workspaces + '/Public/Boss/images/default.png')
                    }
                }
            }

        });
    });

    function submitcheck() {
        var $picid = $("input[name='picid']");
        if ($picid.val() == "") {
            $picid.parents(".form-group").removeClass("has-success").addClass("has-error");
            $picid.parents(".form-group").find(".help-block").show();
            return false;
        }
    }
</script>
</html>
